I'm gonna overwrite a lot of this notebook's old content. I changed the way I'm calculating wt, and wanna test that my training worked.
In [1]:
from pearce.emulator import OriginalRecipe, ExtraCrispy
from pearce.mocks import cat_dict
import numpy as np
from os import path
In [2]:
import matplotlib
#matplotlib.use('Agg')
from matplotlib import pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()
In [3]:
training_dir = '/u/ki/swmclau2/des/PearceLHC_ds_z/'
em_method = 'gp'
split_method = 'random'
In [4]:
%%bash
ls -d ~/des/PearceLHC_wt_z/*
In [5]:
a = 0.81120
z = 1.0/a - 1.0
In [6]:
fixed_params = {'z':z}#, 'r':0.18477483}
In [7]:
emu = OriginalRecipe(training_dir, method = em_method, fixed_params=fixed_params, independent_variable=None)
In [8]:
emu._ordered_params
Out[8]:
In [9]:
print emu.y
In [10]:
emu.x[0,:-1]
Out[10]:
In [11]:
emu._ordered_params.items()
Out[11]:
In [13]:
l = len(emu.scale_bin_centers)
idx = 0
params = {pname:pval for pname, pval in zip(emu._ordered_params.iterkeys(), emu.x[idx*l,:-1])}
In [14]:
params['logMmin'] = 12.1
params['sigma_logM'] = 0.3
params['logM0'] = 12
params['logM1'] = 13.2
params['f_c'] = 0.2
params['alpha'] = 1.0
params['mean_occupation_centrals_assembias_param1'] = 0.0
params['mean_occupation_satellites_assembias_param1'] = 0.0
In [15]:
for k,v in params.iteritems():
print k,'\t'*5,v
In [16]:
ds = emu.emulate_wrt_r(params, emu.scale_bin_centers)[0]
plt.plot(emu.scale_bin_centers, ds, label = 'Emu')
l = len(emu.scale_bin_centers)
plt.plot(emu.scale_bin_centers, emu.y[(idx)*l:(idx+1)*l]+emu.y_hat, label = 'Training')
plt.ylabel(r'$\Delta \Sigma(r)$')
plt.xlabel(r'$r \; \mathrm{[Mpc]}$')
#plt.loglog();
plt.xscale('log')
plt.legend(loc='best')
Out[16]:
In [ ]:
cosmo_params = {'simname':'chinchilla', 'Lbox':400.0, 'scale_factors':[a]}
cat = cat_dict[cosmo_params['simname']](**cosmo_params)#construct the specified catalog!
cat.load_catalog(a, particles = True)
cat.load_model(a, 'hsabRedMagic')
#halo_masses = cat.halocat.halo_table['halo_mvir']
In [ ]:
emu.scale_bin_centers
In [ ]:
scale_bins = np.logspace(-1.1, 1.6, 19)
In [20]:
param_name = 'logMmin'
bounds = emu.get_param_bounds(param_name)
param_vals = np.linspace(bounds[0]+0.1, bounds[1]-0.1, 6)
for pv in param_vals:
params[param_name] = pv
ds = emu.emulate_wrt_r(params, emu.scale_bin_centers)[0]
plt.plot(emu.scale_bin_centers, ds, label = '%.1f'%pv)
plt.title("Emulator w.r.t. %s"%param_name)
plt.ylabel(r'$ \log \Delta \Sigma(r) \mathrm{[h\; M_{\odot}/pc^2]}$')
plt.xlabel(r'$r \; \mathrm{[Mpc]}$')
plt.xscale('log');
#plt.xlim([8e-2, 2e1])
#plt.ylim([1e-2, 5])
plt.legend(loc='best')
Out[20]:
In [ ]:
print wt
In [ ]:
from pearce.mocks import compute_prim_haloprop_bins, cat_dict
In [ ]:
cosmo_params = {'simname':'chinchilla', 'Lbox':400.0, 'scale_factors':[a]}
cat = cat_dict[cosmo_params['simname']](**cosmo_params)#construct the specified catalog!
cat.load_catalog(a)
#halo_masses = cat.halocat.halo_table['halo_mvir']
In [ ]:
cat.load_model(a, 'hsabRedMagic')
In [ ]:
binno = 1
params = {pname:val for pname, val in zip(emu._ordered_params.iterkeys(), emu.x[binno*binlen,:-1])}
cat.populate(params)
wt = cat.calc_wt(theta_bins, do_jackknife=False,n_cores=1)
In [ ]:
theta_bins = np.logspace(np.log10(2.5), np.log10(250), 20)/60
tpoints = (theta_bins[1:]+theta_bins[:-1])/2
In [ ]:
fig = plt.figure(figsize=(45,14))
emulation_point = [('f_c', 0.233), ('logM0', 12.0), ('sigma_logM', 0.333),
('alpha', 1.053),('logM1', 13.5), ('logMmin', 12.033)]
em_params = dict(emulation_point)
em_params.update(fixed_params)
del em_params['z']
fixed_params2 = {'mean_occupation_satellites_assembias_param1':0.0,
'mean_occupation_centrals_assembias_param1':0.0,
'disp_func_slope_satellites':1.0,
'disp_func_slope_centrals':1.0}
for idx, (param, bounds) in enumerate(emu._ordered_params.iteritems()):
if param == 'r':
continue
wt_vals = []
new_em_params = {}
new_em_params.update(em_params)
new_em_params.update(fixed_params2)
for v in np.linspace(bounds[0], bounds[1], 6):
new_em_params[param] = v
wt_vals.append(emu.emulate_wrt_r(new_em_params, tpoints))
wt_vals = np.array(wt_vals)
pal = sns.cubehelix_palette(wt_vals.shape[0], start=idx, rot=0.3,\
dark=0.0, light=.60,reverse = True)
#sns.palplot(pal)
sns.set_palette(pal)
#sns.set_style("darkgrid", {"axes.facecolor": "0.85"})
plt.subplot(5,2,idx+1)
for color, wt, v in zip(pal, wt_vals,np.linspace(bounds[0], bounds[1], 6) ):
plt.plot(tpoints, 1+wt[0,:], color = color, label = r'%s = %.1f'%(param,v) )
#plt.loglog()
plt.xscale('log')
plt.legend(loc='best')
plt.xlim([0.1, 4])
plt.title(r'$w(\theta)$ variance by %s'%param)
plt.xlabel(r'$\theta$')
plt.ylabel(r'$w(\theta)$')
plt.show()
In [ ]: